#ifndef OPDD
#define OPDD

#include "VMPFocus.hpp"
#include "operations.hpp"
#include "op {}.hpp"

// Operation (){}
//formula:
//\((:blank:?:name::blank:?)?(,:blank:?:name::blank:?)*\):blank:?:block:;

cText TEXT_DD="(){}";

//PreLining:

void funOpDDPreL(ListIdentity* what){
	ParserRename(what,TEXT_NAME);
	ParserRename(what,"{}",TEXT_BLOCKTEXT);
	ParserRename(what,"blank",TEXT_BLANK);
}
/*
//PostLining:
void funOpDDPostL(ptrText code, ptrIdentity what){
	what->Extended=(void*)(new cText(code,what->Range)); //Save the Dough Code, by cloning.
};

//MkTree:
void funOpDDMkTree(ptrIdentity identity, ptrParsedElement PE){
	PE->Extended=identity->Extended;
}
*/

void initParams(ptrDough what, ptrParsedElement how){
	ptrParams tmp=new Params();
	what->Extended->push(EXT_PARAM,(void*)(tmp));
	for(int i=0; i<how->SubElements.length()-1; ++i)
		tmp->push(*(ptrText)(how->SubElements[i]->Extended));
}

void initStatics(ptrDough what, ptrParsedElement pe){/* As a user dough, it doen't have any preStatics?....
	//1: code. Text Dough.
	ptrDough c=CreateTextDough(ptrParsedElement->Extended.search(TEXT_CODE));
	what->statics->push(TEXT_Code,c); //usage:(dough).code=xxxxx;
	*/
}
//Evaluate:
sRecord funOpDDEva(ptrRETNode retnode, ptrParsedElement pe, void* nothing){
	//1.Retrieve Dough Parsed Eva Tree.
	ptrParsedElement nPE=pe->SubElements[pe->SubElements.length()-1]->cloneTree();
	//                                                  last Element.cloneTree() ---last Element is :block:
	ptrDough         nD =CreateDough();
	nD->ParsedTree=nPE;
	//2.Dough code passed.
	//nD->Code		  =(ptrText)(pe->Extended);
	//3.Params.
	initParams(nD,pe);
	//4.Statics.
	//initStatics(nD,pe);
	return sRecord(nD);
}


ptrOperation loadOpDD(){
	ptrOperation tmp=new cOperation();
	tmp->Formula="\\(:blank:?:name:?(:blank:?,:blank:?:name:)*:blank:?\\):blank:?:block:";
	tmp->onPreLining=funOpDDPreL;
	tmp->onMakingTree=NULL;
	tmp->onPostLining=NULL;
	tmp->Name=TEXT_DD;
	tmp->onEvaluate=funOpDDEva;
	return tmp;
}
#endif